package com.v.movie.代码;

import com.v.login.Interface;
import com.v.login.Movie;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;

public class View_movie extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4798438251431758209L;

	// 将整个用户界面划分为左右两个面板
	private JPanel jp_Left;// 左边的面板


	// 左边面板内容--开始

	private JButton jb_Refresh;// 刷新按钮
	private JButton jb_signOut;// 退出按钮

	private JLabel jl_Welcome;// 欢迎您的标签
 
	private JLabel jl_HotMovies;// 热门电影的标签
	private JLabel jl_MyTicket;// 我的影票标签
	private JLabel jl_FindMovie;// 查找电影的标签
	private JLabel jl_science;// 科幻的标签
	private JLabel jl_action;// 动作的标签
	private JLabel jl_love;// [表情]的标签

	// 左边面板内容--结束

	private JPanel jp_right;// 右边的面板

	// 右边面板内容--开始

	private JLabel Film_album;// 电影专辑
	private JLabel Film_album1;// 电影专辑
	private JLabel Film_album2;// 电影专辑
	private JLabel Film_album3;// 电影专辑
	private JLabel Film_album4;// 电影专辑
	private JLabel Film_album5;// 电影专辑

	private JTextArea Film_introduction;// 电影简介
	private JTextArea Film_introduction1;// 电影简介
	private JTextArea Film_introduction2;// 电影简介
	private JTextArea Film_introduction3;// 电影简介
	private JTextArea Film_introduction4;// 电影简介
	private JTextArea Film_introduction5;// 电影简介

	// 右边面板内容--结束

	// 显示一个小手
	private Cursor hand = new Cursor(Cursor.HAND_CURSOR);
	private JScrollPane scrollPane;// 滚动界面

	private Child1 child1;//全局变量
	private Child2 child2;//全局变量
	private Child3 child3;//全局变量
	private Child4 child4;//全局变量
	private Child5 child5;//全局变量
	private Child6 child6;//全局变量
	
	public View_movie() {
		// 将整个背景设置为白色背景
		this.getContentPane().setBackground(Color.white);

		//左边的面板
		jp_Left = new JPanel();
		jp_Left.setLayout(null);//设置为绝对布局
		jp_Left.setPreferredSize(new Dimension(130, 0));
		this.add(BorderLayout.WEST,jp_Left);//加入整个面板中
		
		// 右边的面板
		jp_right = new JPanel() {

			// 获得右边面板的背景图片
			private static final long serialVersionUID = -7832851738879922577L;

			@Override
			protected void paintComponent(Graphics g) {
				ImageIcon icon = new ImageIcon(View_movie.class.getResource("背景图片.png"));
				g.drawImage(icon.getImage(), 0, 0, null);
			}

		};
		
		scrollPane = new JScrollPane();
		jp_right.setLayout(null);// 设置为绝对布局
		jp_right.setOpaque(true);// 将右边面板的背景设置为透明
		jp_right.setPreferredSize(new Dimension(1600, 1000));// 设置边界布局的所站的大小
		jp_right.setBounds(130, 0, 870, 645);
      
		// 右边面板=======================================>开始
		Film_album = new JLabel(new ImageIcon(View_movie.class.getResource("荡寇风云.jpg")));
		Film_album.setBounds(60, 2, 220, 340);
		Film_album.setCursor(hand);// 放上去显示小手
		Film_album.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album.setIcon(new ImageIcon(View_movie.class.getResource("荡寇风云-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album.setIcon(new ImageIcon(View_movie.class.getResource("荡寇风云.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {
				//点击启动按钮的时候，创建一个子窗口
				//只要看到new关键字，就会产生一个新的对象，这个新的对象所有的内容初始化了的。
				//内部类获取外部类对象时使用类名.this
				child1 = new Child1(child1, true);
			}
		
		});
		jp_right.add(Film_album);

		Film_introduction = new JTextArea();
		Film_introduction.setBounds(60, 248, 220, 180);
		jp_right.add(Film_introduction);

		Film_album1 = new JLabel(new ImageIcon(View_movie.class.getResource("钢琴教师.jpg")));
		Film_album1.setBounds(312,2, 220, 340);
		Film_album1.setCursor(hand);// 放上去显示小手
		Film_album1.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album1.setIcon(new ImageIcon(View_movie.class.getResource("钢琴教师-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album1.setIcon(new ImageIcon(View_movie.class.getResource("钢琴教师.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {

				child2 = new Child2(child2, true);
			}
		});
		jp_right.add(Film_album1);

		Film_introduction1 = new JTextArea();
		Film_introduction1.setBounds(312,  248, 220, 180);
		jp_right.add(Film_introduction1);

		Film_album2 = new JLabel(new ImageIcon(View_movie.class.getResource("攀登者.jpg")));
		Film_album2.setBounds(554, 2, 220, 340);
		Film_album2.setCursor(hand);// 放上去显示小手
		Film_album2.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album2.setIcon(new ImageIcon(View_movie.class.getResource("攀登者-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album2.setIcon(new ImageIcon(View_movie.class.getResource("攀登者.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {

				child3 = new Child3(child3, true);
			}
		});
		jp_right.add(Film_album2);

		Film_introduction2 = new JTextArea();
		Film_introduction2.setBounds(554, 248, 220, 180);
		jp_right.add(Film_introduction2);

		Film_album3 = new JLabel(new ImageIcon(View_movie.class.getResource("审死官.jpg")));
		Film_album3.setBounds(60, 420, 220, 340);
		Film_album3.setCursor(hand);// 放上去显示小手
		Film_album3.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album3.setIcon(new ImageIcon(View_movie.class.getResource("审死官-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album3.setIcon(new ImageIcon(View_movie.class.getResource("审死官.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {

				child4 = new Child4(child4, true);
			}
		});
		jp_right.add(Film_album3);

		Film_introduction3 = new JTextArea();
		Film_introduction3.setBounds(60, 665, 220, 180);
		jp_right.add(Film_introduction3);

		Film_album4 = new JLabel(new ImageIcon(View_movie.class.getResource("叶问外传：张天志.jpg")));
		Film_album4.setBounds(312, 420, 220, 340);
		Film_album4.setCursor(hand);// 放上去显示小手
		Film_album4.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album4.setIcon(new ImageIcon(View_movie.class.getResource("叶问外传：张天志-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album4.setIcon(new ImageIcon(View_movie.class.getResource("叶问外传：张天志.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {

				child5 = new Child5(child5, true);
			}
		});
		jp_right.add(Film_album4);

		Film_introduction4 = new JTextArea();
		Film_introduction4.setBounds(312, 665, 220, 180);
		jp_right.add(Film_introduction4);

		Film_album5 = new JLabel(new ImageIcon(View_movie.class.getResource("云南虫谷.jpg")));
		Film_album5.setBounds(554, 420, 220, 340);
		Film_album5.setCursor(hand);// 放上去显示小手
		Film_album5.addMouseListener(new MouseAdapter() {
			// 鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				Film_album5.setIcon(new ImageIcon(View_movie.class.getResource("云南虫谷-播放.jpg")));
			}

			// 鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				Film_album5.setIcon(new ImageIcon(View_movie.class.getResource("云南虫谷.jpg")));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {

				child6 = new Child6(child6, true);
			}
		});
		jp_right.add(Film_album5);

		Film_introduction5 = new JTextArea();
		Film_introduction5.setBounds(554, 665, 220, 180);
		jp_right.add(Film_introduction5);
		
		
		
        scrollPane.setViewportView(jp_right);
		this.add(scrollPane);

		
		// 左边面板---------------------------------------------开始>

		//刷新按钮
		jb_Refresh = new JButton("刷新");
		jb_Refresh.setBounds(0, 0, 65, 30);
		jb_Refresh.setFont(new Font("微软雅黑", Font.PLAIN, 15));
		jb_Refresh.setForeground(Color.black);//设置字体颜色
		jb_Refresh.setCursor(hand);//放上去显示小手

		jp_Left.add(jb_Refresh);

		//退出按钮
		jb_signOut = new JButton("退出");
		jb_signOut.setBounds(66, 0, 65, 30);
		jb_signOut.setFont(new Font("微软雅黑", Font.PLAIN, 15));
		jb_signOut.setForeground(Color.black);//设置字体颜色
		jb_signOut.setCursor(hand);//放上去显示小手
		jb_signOut.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		jp_Left.add(jb_signOut);

		//欢迎您的标签
		jl_Welcome = new JLabel("个人信息",JLabel.CENTER);//JLabel.CENTER:设置字体居中
		jl_Welcome.setCursor(hand);//放上去有小手
		jl_Welcome.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_Welcome.setOpaque(true);//设置标签背景为透明
		jl_Welcome.setForeground(Color.black);//设置字体颜色
		jl_Welcome.setBackground(new Color(200,221,242));//设置背景颜色
		jl_Welcome.setBounds(0, 33, 130, 30);//设置位置
		//鼠标监听事件
		jl_Welcome.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_Welcome.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_Welcome.setBackground(new Color(200,221,242));
			}
			//鼠标点击时
			@Override
			public void mouseClicked(MouseEvent e) {

				JTextField j=new JTextField();
				Interface in=new Interface(j);
				dispose();
				jl_Welcome.setBackground(new Color(128, 128, 128));

			}

		});
		jp_Left.add(jl_Welcome);

		//热门电影
		jl_HotMovies = new JLabel("热门电影",JLabel.CENTER);
		jl_HotMovies.setCursor(hand);//放上去显示小手
		jl_HotMovies.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_HotMovies.setOpaque(true);//设置标签背景为透明
		jl_HotMovies.setForeground(Color.black);//设置字体颜色
		jl_HotMovies.setBackground(new Color(200,221,242));//设置背景颜色
		jl_HotMovies.setBounds(0, 66, 130, 30);//设置位置
		//鼠标监听事件
		jl_HotMovies.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_HotMovies.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_HotMovies.setBackground(new Color(200,221,242));
			}

			@Override
			public void mouseClicked(MouseEvent e) {
				new View_movie();
				dispose();
			}
		});
		jp_Left.add(jl_HotMovies);

		//我的影票
		jl_MyTicket = new JLabel("我的影票",JLabel.CENTER);
		jl_MyTicket.setCursor(hand);//放上去显示小手
		jl_MyTicket.setForeground(Color.black);//设置字体颜色
		jl_MyTicket.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_MyTicket.setOpaque(true);//设置标签背景为透明
		jl_MyTicket.setBackground(new Color(200,221,242));//设置背景颜色
		jl_MyTicket.setBounds(0, 99, 130, 30);//设置位置
		//鼠标监听事件
		jl_MyTicket.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_MyTicket.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_MyTicket.setBackground(new Color(200,221,242));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {
				JDialog dialog = new JDialog();
				dialog.setTitle("电影⭕️我的影票");
				dialog.setSize(870, 640);

			    // 标签
				JLabel label = new JLabel(new ImageIcon(View_movie.class.getResource("背景-海.jpg")));
				label.setBounds(0,0,870,640);
				dialog.add(label);

				//字体标签
				JLabel typeface = new JLabel("你已评论");
				typeface.setFont(new Font("微软雅黑",Font.PLAIN,12));
				typeface.setBounds(260,120,60,20);
				typeface.setForeground(Color.black);
				label.add(typeface);
				//更改评论-按钮
				JButton Change_comments = new JButton("更改评论");
				Change_comments.setFont(new Font("微软雅黑",Font.PLAIN,12));
				Change_comments.setBounds(360,100,60,20);
				Change_comments.setForeground(Color.black);
				label.add(Change_comments);

				//发表-按钮
				JButton publish = new JButton("发表");
				publish.setFont(new Font("微软雅黑",Font.PLAIN,12));
				publish.setBounds(500,100,60,20);
				publish.setForeground(Color.black);
				label.add(publish);

				//文本框
				JTextField jT = new JTextField();
				jT.setFont(new Font("微软雅黑",Font.PLAIN,12));
				jT.setBounds(200,160,460,120);
				jT.setForeground(Color.black);
				label.add(jT);

				// 表头（列名）
				Object[] columnNames = {"影院编号", "用户名", "影院名称", "影院地址", "场厅名字","电影名称 ","开始时间","价格","座位号"};

				// 表格所有行数据
				Object[][] rowData = {
						{"1", "那怒多", "长沙影院", "长沙", "一号大厅","攀登者","2020-7-3 12:00",100,35},
						{"2", "撒只给", "长沙影院", "长沙", "二号大厅","迪迦奥特曼","2020-7-6 12:00",100,26},
						{"3", "你要把我整神", "长沙影院", "长沙","三号大厅","葫芦娃","2020-7-2 12:00",100,16},
						{"4", "你过来呀！", "长沙影院", "长沙", "四号大厅","火影忍者","2020-7-8 12:00",100,6},
						{"5", "小灰灰霸主", "长沙影院", "长沙","五号大厅","七龙珠","2020-7-9 12:00",100,45}
				};

				// 创建一个表格，指定 所有行数据 和 表头
				JTable jt_showData = new JTable(rowData, columnNames);
				JTableHeader header = jt_showData.getTableHeader();
				header.setFont(new Font("微软雅黑",Font.PLAIN,12));
				header.setForeground(Color.MAGENTA);
				//设置单元格的样式
				DefaultTableCellRenderer d = new DefaultTableCellRenderer();
				//表格内容居中
				d.setHorizontalAlignment(JLabel.CENTER);
				jt_showData.setDefaultRenderer(Object.class, d);
				jt_showData.setRowHeight(30);//设置表格高度
				//设置表格字体样式
				jt_showData.setFont(new Font("楷体",Font.PLAIN,16));

				jt_showData.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

				JPanel Lower_part = new JPanel();
                Lower_part.setBorder(new LineBorder(new Color(248,248,255),2));
                Lower_part.setBounds(0,310,870,308);

				// 把 表头 添加到容器顶部（使用普通的中间容器添加表格时，表头 和 内容 需要分开添加）
                Lower_part.add(jt_showData.getTableHeader(),BorderLayout.NORTH);

				// 把 表格内容 添加到容器中心
				Lower_part.add(jt_showData, BorderLayout.CENTER);

                label.add(Lower_part);

				//退订
				JButton Unsubscribe = new JButton("退订");
				Unsubscribe.setFont(new Font("微软雅黑",Font.PLAIN,12));
				Unsubscribe.setBounds(660,280,60,20);
				Unsubscribe.setForeground(Color.black);
				label.add(Unsubscribe);

				dialog.setLocationRelativeTo(null);
				dialog.setResizable(false);
				dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);// 关闭模式
				dialog.setVisible(true);// 设置窗口可见

			}
		});
		jp_Left.add(jl_MyTicket);

		//查找电影
		jl_FindMovie = new JLabel("查找电影",JLabel.CENTER);
		jl_FindMovie.setCursor(hand);//放上去显示小手
		jl_FindMovie.setForeground(Color.black);//设置字体颜色
		jl_FindMovie.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_FindMovie.setOpaque(true);//设置标签背景为透明
		jl_FindMovie.setBackground(new Color(200,221,242));//设置背景颜色
		jl_FindMovie.setBounds(0, 132, 130, 30);//设置位置
		//鼠标监听事件
		jl_FindMovie.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_FindMovie.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_FindMovie.setBackground(new Color(200,221,242));
			}
			//鼠标点击标签时会触发
			public void mouseClicked(MouseEvent e) {
			  new Movie();

			}
		});
		jp_Left.add(jl_FindMovie);

		//科幻的标签
		jl_science = new JLabel("科幻",JLabel.CENTER);
		jl_science.setCursor(hand);//放上去显示小手
		jl_science.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_science.setForeground(Color.black);//设置字体颜色
		jl_science.setOpaque(true);//设置标签背景为透明
		jl_science.setBackground(new Color(200,221,242));//设置背景颜色
		jl_science.setBounds(0, 165, 130, 30);//设置位置
		//鼠标监听事件
		jl_science.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_science.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_science.setBackground(new Color(200,221,242));
			}

		});
		jp_Left.add(jl_science);

		//动作的标签
		jl_action = new JLabel("动作",JLabel.CENTER);
		jl_action.setCursor(hand);//放上去显示小手
		jl_action.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_action.setForeground(Color.black);//设置字体颜色
		jl_action.setOpaque(true);//设置标签背景为透明
		jl_action.setBackground(new Color(200,221,242));//设置背景颜色
		jl_action.setBounds(0, 198, 130, 30);//设置位置
		//鼠标监听事件
		jl_action.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_action.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_action.setBackground(new Color(200,221,242));
			}

		});
		jp_Left.add(jl_action);

		//爱情的标签
		jl_love = new JLabel("爱情",JLabel.CENTER);
		jl_love.setCursor(hand);//放上去显示小手
		jl_love.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
		jl_love.setForeground(Color.black);//设置字体颜色
		jl_love.setOpaque(true);//设置标签背景为透明
		jl_love.setBackground(new Color(200,221,242));//设置背景颜色
		jl_love.setBounds(0, 231, 130, 30);//设置位置
		//鼠标监听事件
		jl_love.addMouseListener(new MouseAdapter() {
			//鼠标放上去
			@Override
			public void mouseEntered(MouseEvent e) {
				jl_love.setBackground(new Color(128,128,128));
			}
			//鼠标离开时
			@Override
			public void mouseExited(MouseEvent e) {
				jl_love.setBackground(new Color(200,221,242));
			}

		});
		jp_Left.add(jl_love);

		// 左边面板---------------------------------------------------->结束

		setSize(1000, 645);// 大小
		setTitle("电影购票系统");//
		setLocationRelativeTo(null);// 居中
		setResizable(false);// 窗口不能调大小
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);// 关闭模式
		setVisible(true);// 窗口可见
	}

	public static void main(String[] args) {
		new View_movie();
	}
}
